package com.jikedaquan.game.jwt.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jikedaquan.game.jwt.entity.Message;
import com.jikedaquan.game.jwt.service.MessageService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
 * <p>
 * 世界喊话 前端控制器
 * </p>
 *
 * @author jiake
 * @since 2019-11-5
 */
@Controller
@RequestMapping("/worldSpeak")
public class WorldSpeakController {
    @Resource
    private MessageService messageService;


    @GetMapping(path = {"","/","/index-{index}","/index-{index}.html"})
    public String index(Model model, @PathVariable(value = "index",required = false) Integer index){
        //分页查询
        if (index==null){index=1;}
        if (index>10){index=10;}
        Page<Message> page = new Page<>(1,10);
        messageService.findWorldSpeak(page);
        model.addAttribute("page",page);
        return "worldSpeak/index";
    }

    @GetMapping(path = {"/sendMessage","/sendMessage.html"})
    public String sendMessage(Model model){
        return "worldSpeak/sendMessage";
    }
}
